package com.sumec.config;

import com.sumec.client.Client;
import com.sumec.servlet.UCenterServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {

    @Bean
    public UCenterServlet ucServlet(Client client){
        UCenterServlet ucServlet = new UCenterServlet();
        ucServlet.setClient(client);

        return ucServlet;
    }

    @Bean
    public ServletRegistrationBean registerServlet(UCenterServlet ucServlet) {
        ServletRegistrationBean registration = new ServletRegistrationBean(ucServlet);
        registration.setEnabled(true);
        registration.addUrlMappings("/api/uc.php");
        return registration;
    }
}
